
template <typename T>
class OZBlock{  //a replacement for STL's Vector where I know what's going on. I hope I can optomise this thing
public: //16 bytes
	T   *Block;    //4 Dynamic Array
    int *ID;	  //4 Use the ID's to access an object cause they'll get switched around on delete
	int Buffer; //4 # of Objects currently in the buffer
	int Size; //4 the power of two objects that this block can contain
	OZBlock(int QUEUE_START_SIZE=2){Size = QUEUE_START_SIZE;Buffer =0;Block = new T[2^Size];ID = new int[2^Size];}
	
	int Add(T* obj,int id = -1){ //adds the object and gives you an ID(placement,maybe) of the object
	int Uid = (id == -1)? Buffer:id;//if no ID, then make the ID the current buffer position
	memcpy(&Block[Buffer],(void*)obj,sizeof(T));
	ID[Buffer] =Uid; //I hope this is right
	Buffer += 1;
	if(Buffer >= (2^Size)){ // If we're gunna write out of bounds
		Size++; //double our size
		T *CPY = new T[2^Size]; //reserve the new memory size
		int *IDC = new int[2^Size];
		CopyMemory(CPY,Block,(2^(Size-1))*sizeof(T)); //2*Size,where 2 is one half of QUEUE_START_SIZE, it saves a calculation.
		CopyMemory(IDC,ID,(2^(Size-1))*sizeof(int));
		delete Block;
		delete ID;
		ID = IDC;//set the two  equal to each other
		Block =CPY;
		//IDC and CPY both go out of scope without memory leaks, right?
		} 
	return Uid; 
	}

	T* operator [](int id){for(int i=0; i<(Buffer); i++){if(id == ID[i]){return Block[i];}}return NULL;} //get pointer to
		
	T* GetBlock(int id){return Block;} //returns the whole deal

	void Delete(int id){for(int i=0; i<(Buffer); i++){if(id == ID[i]){ //sets the deleted element to the last element,
		memcpy(Block[i],Block[Buffer-1],sizeof(T)); *ID[i]=*ID[Buffer-1]; Buffer--;}}} //this way, we keep the dataset unfragmented by moving one, and not shifting all
};


